package com.kakavr.recharge.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.beust.jcommander.internal.Maps;
import com.kakavr.base.controller.BaseController;
import com.kakavr.result.MsgResult;
import com.kakavr.work.service.IWorkRecordService;
/**
 * 平台员工打卡
 * @author gang.yang
 *
 */
@RestController
@RequestMapping("commission")
public class RecharegeCommissionController extends BaseController {
	@Resource
	private IWorkRecordService workRecordService;
	
	/**
	 * 上班记录
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "selectWorkList", method = RequestMethod.GET)
	public Map<String, Object> selectWorkList(HttpServletRequest request) {
		String storeId = request.getParameter("storeId");
		Map<String, Object> map = this.initPaginationParams(request);
		if(StringUtils.isNotBlank(storeId)){
			map.put("storeId", storeId);
		}
		map.put("begin", request.getParameter("begin"));
		map.put("end", request.getParameter("end"));
		return MsgResult.okResultData(workRecordService.selectWorkList(map));
	}

	/**
	 * 统计一个时间段内各个人员的提成
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "staticWorkUser", method = RequestMethod.GET)
	public Map<String, Object> staticWorkUser(HttpServletRequest request) {
		String storeId = request.getParameter("storeId");
		Map<String, Object> map = Maps.newHashMap();
		if(StringUtils.isNotBlank(storeId)){
			map.put("storeId", storeId);
		}
		map.put("begin", request.getParameter("begin"));
		map.put("end", request.getParameter("end"));
		map.put("staffType", 1);
		return MsgResult.okResultData(workRecordService.staticWorkUser(map));
	}

}
